﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using KorbeRTR.Models;

namespace KorbeRTR
{
    public partial class FormError修改 : Form
    {
        private AlarmCode code;

        public FormError修改(AlarmCode p)
        {
            InitializeComponent();

            code = p;
        }

        private void btn取消_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btn保存_Click(object sender, EventArgs e)
        {
            code.Content = txt故障内容.Text.Trim();

            if (AlarmCode.UpdateWhereAddrAndSubAddr(code))
            {
                Close();
            }             
            else
            {
                MessageBox.Show("修改故障列表失败，请检查数据格式","提示");
            }

        }

        private void FormError修改_Load(object sender, EventArgs e)
        {
            txt单元号.Text = code.Addr.ToString();
            txt位地址.Text = code.SubAddr.ToString();
            txt绝对地址.Text = code.AbsAddr;
            txt故障代码.Text = code.Code.ToString();
            txt故障内容.Text = code.Content;
            txt故障类型.Text = code.AlarmType;
            cbx系统是否处理此故障.Checked = code.Handle;
            txt槽号.Text = code.Slot.ToString();
        }
    }
}
